package com.example.dao;

import com.example.model.Blog;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface BlogMapper {
    //查询所有
    @Select("select * from t_blog")
    List<Blog> selectBlog();
    //根据id查询
    @Select("select * from t_blog where id = #{id}")
    List<Blog> selectBlogById(Integer id);
    //根据title查询
    @Select("select * from t_blog where title like concat('%',#{title},'%')")
    List<Blog> selectBlogByTitle(Map<String,Object> map);
    //添加
    @Insert("insert into t_blog (title,content) values (#{title},#{content})")
    int addBlog(Blog blog);
    //修改
    @Update("update t_blog set title=#{title},content=#{content} where id=#{id}")
    int updateBlog(Blog blog);
    //删除
    @Delete("delete from t_blog where id=#{id}")
    int deleteBlog(Integer id);
}
